// Version 2.0, Lu Lin Qi, Aug-21 2012
﻿Session = {
    _userInfo: { UserID: "", UserName: "", UserGuid: "", DeptGuid: "", DeptName: "", CompanyGuid: "", CompanyName: "" },
    LoginUser: function () {
        var loginUrl = "/Pages/Login.htm";
        var curUrl = window.location.href.toLowerCase();
        var userInfo = Session._userInfo;
        if (curUrl.substr(curUrl.length - loginUrl.length, loginUrl.length) != loginUrl.toLowerCase()) {
            if (userInfo.UserGuid == undefined || userInfo.UserGuid == "") {
                var arrStr = document.cookie.split("; ");
                for (var i = 0; i < arrStr.length; i++) {
                    var temp = arrStr[i].split("=");
                    //var key = temp[0];
                    //var value = temp[1];
                    //userInfo = $.extend({},userInfo,{key: value});
                    var key;
                    for (key in userInfo) {
                        if (key == temp[0]) {
                            userInfo[key] = unescape(temp[1]);
                        }
                    }
                }
            }
            if(userInfo.UserGuid==""){
                alert("no login");
                window.location.href = loginUrl;
            }
        }
        return userInfo;
    },
    Logout: function () {
        var usrInfo;
        for (usrInfo in Session.LoginUser) {
            if (Session.LoginUser[usrInfo] == undefined || typeof Session.LoginUser[usrInfo] == "string") {
                Session.LoginUser[usrInfo] = "";
            } else {
                Session.LoginUser[usrInfo] = 0;
            }
        }
    }
};

SysConstant = {};
SysConstant.Common = {
    NewGuid: "NewGuid",
    DelStr: "<Document TaskGuid =\'{0}\' DataGuid =\'{1}\' DataType = \'{2}\'></Document>"
};
SysConstant.Service = {
    ServicePath: "/PublicService/LocalCommunicate.asmx",

    GetDataFunctionName: "/GetData",
    SetDataFunctionName: "/SetData",
    TransformFunctionName: "/TransformData",
    SaveLogFunctionName: "/SaveLog",
    LocalPath: "/Local/"
};
SysConstant.TaskGuid = {
    Platform: "",
    GlobalInfo: "e32cc6ac-199c-4a6f-93f8-937d3e482d13",        //系统数据源标识
    OrgInfo: "0690f841-7773-445c-9f48-a7a0427686d5",            //组织机构标识
    MsgInfo: "6a6735d4-07db-4974-b2e6-51910c75e3b0",
    WebForm: "e71d92eb-0f16-46e5-ad25-149ed0fbb94a",            //电子表单标识
    ExtComponent: "59f912b5-1236-4cf3-8260-56ad87bc64db"
};



//Constant.SysTemplate.OrgInfo.Login = "<Document TaskGuid=\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"PageTicket\"><UserNameTicket><UserName/><Password/><VerifyCode/></UserNameTicket></Document>";
//Constant.SysTemplate.OrgInfo.CompanyInfo = "<Document TaskGuid =\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"Company\"><Guid Type = \"GUID\"></Guid><Name Type =\"TEXT\"></Name><Domain Type =\"TEXT\"></Domain><MasterGuid Type =\"GUID\"></MasterGuid><EventerGuid Type =\"GUID\"></EventerGuid><Telephone Type =\"TEXT\"></Telephone><EMail Type =\"TEXT\"></EMail><MasterType Type =\"TEXT\"></MasterType><SubType Type =\"TEXT\"></SubType><Order Type =\"LONG\"></Order></Document>";
//Constant.SysTemplate.OrgInfo.BranchInfo = "<Document TaskGuid =\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"Branch\"><Guid Type = \"GUID\"></Guid><Name Type =\"TEXT\"></Name><Number Type =\"TEXT\"></Number><CompanyGuid Type =\"GUID\"></CompanyGuid><ParentGuid Type =\"GUID\"></ParentGuid><MasterGuid Type =\"GUID\"></MasterGuid><MasterName Type =\"TEXT\"></MasterName><LeaderGuid Type =\"GUID\"></LeaderGuid><LeaderName Type =\"TEXT\"></LeaderName><Telephone Type =\"TEXT\"></Telephone><EMail Type =\"TEXT\"></EMail><Order Type =\"LONG\"></Order></Document>";
//Constant.SysTemplate.OrgInfo.MemberInfo = "<Document TaskGuid =\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"Member\"><Guid Type = \"GUID\"></Guid><Name Type =\"TEXT\"></Name><BranchGuid Type =\"GUID\"></BranchGuid><BranchName Type =\"GUID\"></BranchName><Telephone Type =\"TEXT\"></Telephone><Handphone1 Type =\"TEXT\"></Handphone1><Handphone2 Type =\"TEXT\"></Handphone2><EMail Type =\"TEXT\"></EMail><Order Type =\"LONG\"></Order></Document>";
//Constant.SysTemplate.OrgInfo.DelStr = "<Document TaskGuid =\'" + SysConstant.TaskGuid.OrgInfo + "\' DataGuid =\'{0}\' DataType = \'{1}\'></Document>";
//Constant.SysTemplate.OrgInfo.GroupMember = "<Document TaskGuid =\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"GroupMember\"><Guid Type = \"GUID\"></Guid><Name Type =\"TEXT\"></Name><GroupGuid Type =\"GUID\"></GroupGuid><MemberGuid Type =\"TEXT\"></MemberGuid><Type Type =\"TEXT\"></Type><Order Type =\"LONG\"></Order></Document>";
//Constant.SysTemplate.OrgInfo.Account = "<Document TaskGuid =\"" + SysConstant.TaskGuid.OrgInfo + "\" DataGuid =\"\" DataType = \"Account\"><Guid Type = \"GUID\"></Guid><AccountName Type =\"TEXT\"></AccountName><Password Type =\"GUID\"></Password><Type Type =\"TEXT\"></Type><Name Type =\"TEXT\"></Name><IsEvection></IsEvection><Status></Status></Document>";

//Constant.SysTemplate.UsrIntr = {};
//Constant.SysTemplate.UsrIntr.CodeTableList = "<Document TaskGuid=\'" + SysConstant.TaskGuid.ExtComponent + "\' DataGuid=\"\" DataType = \"CodeTableList\"><CodeCategory Type=\"TEXT\">{0}</CodeCategory><Status Type=\"TEXT\">{1}</Status></Document>";
//Constant.SysTemplate.UsrIntr.SequenceInfo = "<Document TaskGuid=\'" + SysConstant.TaskGuid.ExtComponent + "\' DataGuid=\"\" DataType = \"SysSequence\"><DataType Type=\"TEXT\">{0}</DataType></Document>";
//Constant.SysTemplate.UsrIntr.SysCodeList = "<Document TaskGuid=\'" + SysConstant.TaskGuid.ExtComponent + "\' DataGuid=\"\" DataType = \"SysCodeList\"><CodeCategory>{0}</CodeCategory><ParentGuid>{1}</ParentGuid><IncludeSubCode>{2}</IncludeSubCode></Document>";
//Constant.SysTemplate.UsrIntr.SysCodeTable = "<Document TaskGuid=\"" + SysConstant.TaskGuid.ExtComponent + "\" DataGuid=\"\" DataType=\"SysCodeTable\"><CodeGuid/><CodeCategory/><ParentGuid/><CodeName/><CodeValue/><CodeStatus/><CodeOrder/></Document>";
//Constant.SysTemplate.UsrIntr.DelStr = "<Document TaskGuid =\'" + SysConstant.TaskGuid.ExtComponent + "\' DataGuid =\'{0}\' DataType = \'{1}\'></Document>";

//Constant.SysTemplate.MsgInfo = {};
//Constant.SysTemplate.MsgInfo.QueryMessageInfo = "<Document TaskGuid=\'"+SysConstant.TaskGuid.MsgInfo+"\'  DataType=\"QueryMessageInfo\"><MessageGuid Type=\"GUID\"></MessageGuid><Keyword Type=\"TEXT\"></Keyword><AppName Type=\"TEXT\"></AppName><OUGuid Type=\"GUID\"></OUGuid><OUName Type=\"TEXT\"></OUName><DataType Type=\"TEXT\"></DataType ><Status Type=\"TEXT\">未处理</Status><Content Type=\"TEXT\"></Content><Priority Type=\"TEXT\"></Priority><BeginTime Type=\"DATE\"></BeginTime><EndTime Type=\"DATE\"></EndTime><RelationStatus Type=\"TEXT\"></RelationStatus><SortMethod Type=\"TEXT\">StartTime</SortMethod><OrderMethod Type=\"TEXT\">desc</OrderMethod><PageSize Type=\"LONG\">20</PageSize><CurrentPage Type=\"LONG\">0</CurrentPage></Document>";
